package com.gf.forcesystem.mq;

import com.gf.forcesystem.config.CotaskingRabbitmqConfig;
import com.gf.forcesystem.model.dto.CotaskingTargetState;
import com.gf.forcesystem.api.CotaskingTargetStateService;
import com.gf.framework.common.json.GfJsonMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author gaofei
 * @date 2022/6/19 15:30
 * 模型状态 mq队列处理
 */
@Component
@Slf4j
public class TargetStateMqReciver {
    @Resource
    List<CotaskingTargetStateService> cotaskingTargetStateServices;

//    @RabbitListener(queues = CotaskingRabbitmqConfig.targetStateQueue)
//    @RabbitHandler
//    public void recv(String data) {
//        CotaskingTargetState cotaskingTargetState = GfJsonMapper.string2Obj(data, CotaskingTargetState.class);
//        if (cotaskingTargetState == null) {
//            log.warn("CotaskingRabbitMqReciver 收到无法解析的数据: {}", data);
//            return;
//        }
//        if (CollectionUtils.isEmpty(cotaskingTargetStateServices))
//            return;
//
//        for (CotaskingTargetStateService cotaskingTargetStateService : cotaskingTargetStateServices) {
//            try {
//                cotaskingTargetStateService.deal(cotaskingTargetState);
//            } catch (Exception e) {
//                log.error("{} 处理模型状态帧出错", cotaskingTargetStateService.getClass().getName(), e);
//            }
//        }
//    }
}
